package tree.递归;

import po.TreeNode;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 二叉树剪枝814.java
 * @Description https://leetcode-cn.com/problems/binary-tree-pruning/
 * @createTime 2021年07月12日 19:36:00
 */
public class 二叉树剪枝814 {
    public TreeNode pruneTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        root.left= pruneTree(root.left);
        root.right = pruneTree(root.right);
        if (root.val == 1 || root.left != null || root.right != null) {
            return root;
        }
        return null;
    }
}
